<template>
  <div>
    <!-- 年度开工率 -->
    <Echart
      :options="options"
      id="energyMiddleBottomLeftChart"
      height="2.5rem"
      width="100%"
    ></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart'
export default {
  data () {
    return {
      options: {},
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
  },
  watch: {
    cdata: {
      handler (newData) {
        this.options = {
          title: {
            text: "",
          },
          tooltip: {
            trigger: "axis",
            backgroundColor: "rgba(255,255,255,0.1)",
            borderWidth:0,
            textStyle: {
              color: "#d5d5d5"
            },
            axisPointer: {
              type: "shadow",
              label: {
                show: true,
                backgroundColor: "#7B7DDC"
              }
            }
          },
          grid: {
            x: "8%",
            width: "86%",
            y: "20%"
          },
          xAxis: {
            type: 'category',
            data: newData.category,
            axisLabel: { interval: 0, rotate: 30, fontSize: 8 },
          },
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [{
            data: newData.lineData,
            type: 'line',
            smooth: false
          }
          ]
        }
      },
      immediate: true,
      deep: true
    },
  },
}
</script>
